{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "b308f1f0-06cd-48ab-a80c-937bbc37fae0",
   "metadata": {
    "execution": {
     "shell.execute_reply.end": "2023-03-10T03:54:20.006670Z",
     "shell.execute_reply.started": "2023-03-10T03:54:19.990510Z",
     "to_execute": "2023-03-10T03:54:19.845Z"
    }
   },
   "outputs": [],
   "source": [
    "import warnings\n",
    "warnings.filterwarnings(\"ignore\")\n",
    "import numpy as np\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "28abb1c9-db3b-4d28-958c-4d8686dd994a",
   "metadata": {
    "execution": {
     "shell.execute_reply.end": "2023-03-10T03:54:21.582107Z",
     "shell.execute_reply.started": "2023-03-10T03:54:21.547333Z",
     "to_execute": "2023-03-10T03:54:21.455Z"
    }
   },
   "outputs": [],
   "source": [
    "import random\n",
    "from trailblazer4ml.causal_discovery.datasets.easydataset import EasyDataset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "12a18ea7-f43c-4eaf-a984-353b7371060a",
   "metadata": {
    "execution": {
     "shell.execute_reply.end": "2023-03-10T03:55:17.573502Z",
     "shell.execute_reply.started": "2023-03-10T03:55:17.474876Z",
     "to_execute": "2023-03-10T03:55:17.317Z"
    }
   },
   "outputs": [],
   "source": [
    "df = pd.read_csv(\"../trailblazer/trailblazer4ml/causal_inference/datasets/data/lalonde.csv\")\n",
    "covariates = ['age', 'educ', 'black', 'hispan', 'married', 'nodegree']\n",
    "treat = ['treat']\n",
    "outcomes = ['re78']\n",
    "data = EasyDataset(df, covariates, treat, outcomes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "dca1fda8-e28f-481a-ba06-1c40672ac108",
   "metadata": {
    "execution": {
     "shell.execute_reply.end": "2023-03-10T03:55:18.775654Z",
     "shell.execute_reply.started": "2023-03-10T03:55:18.284643Z",
     "to_execute": "2023-03-10T03:55:18.158Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Data size: 614\n",
      "[[0 1 0 0 1 0 0 0]\n",
      " [0 0 0 1 0 1 0 1]\n",
      " [0 0 0 1 0 0 1 0]\n",
      " [0 0 0 0 0 0 0 0]\n",
      " [0 0 1 0 0 0 1 1]\n",
      " [0 0 0 0 0 0 1 0]\n",
      " [0 0 0 0 0 0 0 0]\n",
      " [0 0 0 0 0 0 0 0]]\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>method</th>\n",
       "      <th>edge_start</th>\n",
       "      <th>edge_end</th>\n",
       "      <th>estimate_value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>PC</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>PC</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>PC</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>PC</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>PC</td>\n",
       "      <td>1</td>\n",
       "      <td>7</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>PC</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>PC</td>\n",
       "      <td>2</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>PC</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>PC</td>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>PC</td>\n",
       "      <td>4</td>\n",
       "      <td>7</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>PC</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   method  edge_start  edge_end  estimate_value\n",
       "0      PC           0         1               1\n",
       "1      PC           0         4               1\n",
       "2      PC           1         3               1\n",
       "3      PC           1         5               1\n",
       "4      PC           1         7               1\n",
       "5      PC           2         3               1\n",
       "6      PC           2         6               1\n",
       "7      PC           4         2               1\n",
       "8      PC           4         6               1\n",
       "9      PC           4         7               1\n",
       "10     PC           5         6               1"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from trailblazer4ml.causal_discovery.estimators.PC_based import PC\n",
    "out = PC(data)\n",
    "out._get_adjacent_matrix()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2de9e9ca-e485-4ca2-9336-d28d9a492218",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
